<?

$frame_count = count($this_folder->pimp_files);
$frame_commands = array ("7" => "frameto(-2)",
						 "3" => "frameto(-1)",
						 ";" => "framegg()",
						 "4" => "frameto(1)",
						 "8" => "frameto(-3)" 
						 );
$pda_commands   = array ("back" => "frameto(-1)",
						 "pause" => "framegg()",
						 "next" => "frameto(1)" 
						 );
print "
&nbsp; 
<input id=framenumber onchange=\"frameto(dm('framenumber').value)\" size=2 value='?' style='color:red'>&nbsp;of&nbsp;$frame_count 
&nbsp;&nbsp;Rate: <input id='irate' size='2' value='".($is_pocketpc?10:5)."'> /sec"; 

if ($is_pocketpc) {	
    print "<br>";
	while (list($text, $command) = each($pda_commands)) 
		print "<a href='javascript:".$command."'><u>$text</u></a>&nbsp;";
} else {
    print "&nbsp;&nbsp;";
	while (list($text, $command) = each($frame_commands)) 
		print "<a href='javascript:".$command."'><font face='webdings'>$text</font></a>";
}
	
print "<"."script>";
print "var dd=new Array(),dn=".($selected_file_index==""?0:$selected_file_index).",dm=MM_findObj,dk=null,re=null,rn=0,rc=5;";
while (list($file_info_key, $file_info_data) = each($this_folder->pimp_files)) 
	   print "dd[dd.length]=\"" . $file_info_data["path"]."\";";


print "function frameup() 
{    
	showstatus ('Loading Picture '+(1+dn)+': '+filetitle(dd[dn]));
	var H=ISPDA?0:document.body.offsetHeight-(PREVIEWFLAG=='on'?80:200);
	var d=dm('mainpic'); 
	var z=dm('detailpic'); 
    try
	{
	    d.onload=frameit;
    }
	catch (ex)
	{
	
	}
	if (z) z.src='thumbnail.php?sd=sd&w=140&i='+dd[dn];
	d.src=ISPDA?'thumbnail.php?sd=sd&w=240&i='+dd[dn]:'thumbnail.php?sd=sd&tag=exec&h='+H+'&i='+dd[dn];
	
	dn++;
	if(dn>=dd.length) dn=0; 
	if (ISPDA) {
	    dk=window.setTimeout ('frameup()', dm('irate').value*1000);		
		dm('framenumber').value = dn;
	}
}
function frameit() 
{     
	checkrate();
	addglobal ('f',dn);
	showstatus ('Picture '+dn+': '+filetitle(dd[dn-1]),'teal','lime');
	desktop_background_resize();
	dm('framenumber').value=dn;
	dk=window.setTimeout ('frameup()', dm('irate').value*1000);		
}
function checkrate() 
{ 
	var error_message = '';
	if (isNaN(dm('irate').value)) 
		error_message= ('Frame rate must be a number!');  
	if (dm('irate').value<1) 
		error_message= ('Frame rate must be an integer greater than 0!');  
	if (error_message!='') {
		alert (error_message);
		dm('irate').value = 5;
	}
} 
function checkframe() 
{	
	var error_message = '';
	if (isNaN(dm('framenumber').value)) 
		error_message= ('Frame number must be a number!');  
	if (dm('framenumber').value>dd.length)  
		error_message= ('Frame number must be an integer less than '+dd.length+'!');  
	if (dm('framenumber').value<1)  
		error_message= ('Frame number must be an integer greater than 0!');  
	if (error_message!='') {
		alert (error_message);
		dm('framenumber').value = dn;
	}
}
function frameon() 
{    
	var d=dm('mainpic');
	if (!ISPDA) { 
	    d.onload=frameit; 
	    d.onerror=frameop;
	} 
	frameup();  
} 
function frameop() 
{
	if (dk) {
		window.clearTimeout (dk);
		dk=null; 
	}
	if (rc>0) {
		showstatus ('Error: '+filetitle(dd[dn-1])+'. Retrying in '+rc+'...','gold','red');
		rc--;
		re=window.setTimeout ('frameop()', 1000);		
	} else if (rn<4) {
		dn--;
		rn++;
		frameon();
	} else {
		frameon();
		re=null;
		rn=0;
		rc=5;
	}
} 
function frameto(i) 
{   
	checkframe() ;
	window.clearTimeout (dk);
	dk=null;
	if (i==-2) dn=0;
	else if (i==-3) dn=dd.length-1;
	else if (i>1) dn=i-1;
	else dn+=i-1;
	if (dn<0) dn=dd.length-1;
	if (dn>=dd.length) dn=0;	
	frameup();	
}
function framegg() 
{   
	hidestatus();
	if (dk==null) frameon();
	else {
		window.clearTimeout (dk);
		dk=null;
		showstatus ('Paused...  <a style=color:white href=javascript:framegg()>Click here to continue</a>');
	} 
} ";
print "addglobal('v','');frameon(); ";

print "</"."script>";
?>